package name.matthewgreet.example14.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import name.matthewgreet.strutscommons.annotation.Required.MessageType; /** * <P>Defines error message to display if a date form field (whether on a Struts Action or model of ModelDriven Struts * Action) is within an age range.</P> * * <P>By default, messages are added to the actionErrors list but this can be overridden by <CODE>messageType</CODE>:</P> * <DL> * <DT>ERROR</DT><DD>Message added to Action level error messages. Default.</DD> * <DT>FIELD</DT><DD>Message added to field error messages.</DD> * <DT>MESSAGE</DT><DD>Message added to Action level info messages.</DD> * <DT>WARNING</DT><DD>Message added to Action level warning messages.</DD> * </DL> * * <P>Other parameters</P> * <DL> * <DT>minAge</DT><DD>Minimum age allowed. No default.</DD> * <DT>maxAge</DT><DD>Maximum age allowed. No default.</DD> * <DT>minAgeMessage</DT><DD>If not empty string, text message to display for failing minAge. Used if * <CODE>messageKey</CODE> is not set or finds no message.</DD> * <DT>minAgeMessageKey</DT><DD>If not empty string, message key to retrieve from Action's TextProvider for failing * minAge. Uses <CODE>message</CODE> if no key provided or no message found.</DD> * <DT>maxAgeMessage</DT><DD>If not empty string, text message to display for failing maxAge. Used if * <CODE>messageKey</CODE> is not set or finds no message.</DD> * <DT>maxAgeMessageKey</DT><DD>If not empty string, message key to retrieve from Action's TextProvider for failing * maxAge. Uses <CODE>message</CODE> if no key provided or no message found.</DD> * <DT>shortCircuit</DT><DD>If true and this validation fails, skips further validation. Defaults to false.</DD> * </DL> */ @Documented @Inherited @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface AgeRange { public int minAge(); public int maxAge(); public String minAgeMessage() default ""; public String minAgeMessageKey() default ""; public String maxAgeMessage() default ""; public String maxAgeMessageKey() default ""; public MessageType messageType() default MessageType.ERROR; public boolean shortCircuit() default false; }